//
//  ViewController1.m
//  CHDropViewControllerExample
//
//  Created by hyc on 16/9/9.
//  Copyright © 2016年 hyc. All rights reserved.
//

#import "ViewController1.h"
#import "CHDropViewController.h"

@interface ViewController1 ()

@property(nonatomic,strong)CHDropViewController *vc;
@property(nonatomic,strong)NSArray *topList;

@end

@implementation ViewController1

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _topList = @[@"蜀国",@"魏国",@"吴国"];
    
    _vc = [[CHDropViewController alloc] init];
    __weak ViewController1 *weakSelf = self;
    CGFloat vc_y = 108;
    [_vc setTopViewAutoSize:YES];
    [_vc setSecHidden:YES];
    [_vc setTopViewFrame:CGRectMake(100, vc_y, CH_WIDTH/2, CH_HEIGHT/2)];
    _vc.topBgColor = [UIColor colorWithRed:245.0/255 green:252.0/255 blue:1 alpha:1];
    _vc.secBgColor = [UIColor colorWithRed:245.0/255 green:252.0/255 blue:1 alpha:1];
    _vc.secCellColor = [UIColor colorWithRed:230.0/255 green:252.0/255 blue:1 alpha:1];
    _vc.topSelectCellColor = [UIColor colorWithRed:230.0/255 green:252.0/255 blue:1 alpha:1];
    _vc.secSelectCellColor = [UIColor colorWithRed:210.0/255 green:252.0/255 blue:1 alpha:1];
    [_vc setTopViewSelectCellAtRow:0];
    [_vc setSecViewSelectCellAtRow:0];
    [_vc setNumberOfTopCell:^NSInteger(UITableView *tableView) {
        return weakSelf.topList.count;
    }];
    [_vc setTopCell:^UITableViewCell *(UITableView *tableView,NSInteger row) {
        //这里可以根据实际情况自定义出满足具体业务需求的cell
        static NSString *cellIdentifier = @"cell";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
        if (cell==nil) {
            cell = [[UITableViewCell alloc] init];
        }
        cell.textLabel.text = weakSelf.topList[row];
        cell.textLabel.font = [UIFont systemFontOfSize:14];
        return cell;
    }];
    
    [_vc setSelectTopCell:^(NSInteger row) {

    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.row==0) {
        [_vc setPushStyle:NO];
        [_vc setTopViewFrame:CGRectMake(0, 128, CH_WIDTH/2, CH_HEIGHT/2)];
        [self presentViewController:_vc animated:YES completion:nil];
    }else if (indexPath.row==1){
        [_vc setPushStyle:YES];
        [_vc setTopViewFrame:CGRectMake(0, 64, CH_WIDTH, CH_HEIGHT-64)];
        [self.navigationController pushViewController:_vc animated:YES];
    }
}

@end
